import React, { Component } from 'react';
import { Text, StyleSheet, View, Button, Alert, StatusBar, Switch, ActivityIndicator } from 'react-native';

export default class index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            isOpen: false,
        };
    }
    toggleStatusBar = () => {
        this.setState({
            isOpen: !this.state.isOpen,
        });
    };
    threeFn = () => {
        Alert.alert(
            '提示',
            '确定删除吗？',
            [
                { text: '重新尝试', onPress: () => { console.log('重新尝试'); } },
                { text: '取消', onPress: () => { console.log('取消'); } },
                { text: '确定', onPress: () => { console.log('确定'); } },
            ]
        );
    };
    render() {
        return (
            <View>
                <Text> Button Alert </Text>
                <Button
                    title="三个按钮"
                    onPress={this.threeFn}

                />
                {/* 控制状态栏 */}
                <StatusBar
                    hidden={this.state.isOpen}
                    barStyle="dark-content"
                    backgroundColor={'red'}
                />
                {/* 开关 */}
                <Switch
                    trackColor={{ false: '#999', true: '#333' }}
                    thumbColor={this.state.isOpen ? 'red' : 'white'}
                    value={this.state.isOpen}
                    onValueChange={this.toggleStatusBar}
                />
                {/* 加载loading */}
                <ActivityIndicator
                    size={77}
                    color={'red'}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({

});
